<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>金字塔</title>
</head>
<style>
    body{
        font-family: cursive;
    }
</style>
<body>
<script>
    var p = prompt("输入金字塔的层数");
    var i = 1;
    while (i <= p){
        var nbsp = p - i;
        var j = 0;
        while (j < nbsp){
            document.write("&nbsp;");
            j++;
        }
        var star = i*2-1;
        var k = 0;
        while (k < star){
            document.write("*");
            k++;
        }
        document.write("<br>");
        i++;
    }
</script>
</body>
</html>